<?php
// +----------------------------------------------------------------------
// | WoShiMaiJia Projcet 
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://woshimaijia.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: xinqiyang <517577550@qq.com>
// +----------------------------------------------------------------------
/**
 * 评论Model
 * @author xinqiyang
 * @date   2010-7-7
 *
 */
class CommentModel extends MetaModel
{


	protected $_validate  = array(
	array ('objectid','require','评论体ID不能为空',1,'',3),
	array ('model','require','模块不能为空',1,'',3),
	array ('content','require','评论内容不能为空',1,'',3),	
	);


	protected $_auto = array(
	array ('ip','get_client_ip',3,'function'),
	array ('createtime','time',3,'function'),
	array ('stauts',1),
	array ('user_id','userID',3,'function'),
	);
	
	/**
	 * 调用评论
	 * @param $arr 对象ID数组
	 * @param $model 对象模型
	 */
	function getComments($arr,$model,$limit=8)
	{
		return $this->query("select sz_comment.id,sz_comment.content,sz_comment.createtime,sz_user.id as uid,sz_user.cnname,sz_$model.id as mid,sz_$model.title,sz_image.url,sz_image.model,sz_image.filename from sz_comment,sz_image,sz_user,sz_$model where sz_comment.status=1   and sz_$model.id =sz_comment.objectid and sz_user.image_id = sz_image.id and sz_comment.user_id = sz_user.id and sz_comment.model='$model' and sz_comment.objectid in ".$arr.' order by sz_comment.id desc limit 0,'.$limit); 
	}
}
?>